package com.wlr.study.pointsword;

/**
 * 斐波那契数列
 * F(N) = F(N - 1) + F(N - 2), 其中 N > 1.
 *
 * @author lrwang
 * @version 1.0
 * @date 2022/4/2 22:12
 */
public class Offer10_1 {
    public int fib(int n) {
        if (n < 2) {
            return n;
        }
        int a = 0, b = 0, c = 1;
        for (int i = 2; i < n; i++) {
            a = b;
            b = c;
            c = (a + b) % 1000000007;
        }
        return c;
    }

    public static void main(String[] args) {
        Offer10_1 offer1 = new Offer10_1();
        System.out.println(offer1.fib(100));
    }
}
